<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //如何改变promise的状态
        //(1) resolve(value):  如果当前是pending就会变为fulfilled
        //(2) reject(reason):  如果当前是pending就会变为rejected
        //(3) 抛出异常: 如果当前是pending就会变为rejected

        const p = new Promise((resolve, reject) => {
            //resolve();  // pending就会变为fulfilled
            //reject();  // pending就会变为rejected
            //console.log(mm); // 报错时 pending就会变为rejected
            throw new Error("error"); // 抛出错误 pending就会变为rejected
            
        });

        console.log(p);
    </script>
</body>
</html>